Object.defineProperty(exports, "__esModule", {
  value: true
});
var def_Subpub = function () {
  function _ctor(t) {
    undefined === t && (t = {});
    this.idx = 0;
    this.config = {};
    this.idx = _ctor.subPubUniqueIdx++;
    this.config = t;
  }
  _ctor.clearAll = function () {
    _ctor.subPubUniqueIdx = 1;
    _ctor.subRec = {};
  };
  _ctor.prototype.subscribe = function (t, o) {
    _ctor.subRec[t] || (_ctor.subRec[t] = {});
    _ctor.subRec[t][this.idx] = {
      cb: o
    };
  };
  _ctor.prototype.deSubscribe = function (t) {
    _ctor.subRec[t] && delete _ctor.subRec[t][this.idx];
  };
  _ctor.prototype.publish = function (t, o) {
    for (var a in _ctor.subRec[t]) {
      _ctor.subRec[t][a].cb(this.idx, o, this.config);
    }
  };
  _ctor.publishEx = function (t, o) {
    undefined === o && (o = {});
    for (var a in _ctor.subRec[t]) {
      try {
        _ctor.subRec[t][a].cb(-1, o, {});
      } catch (e) {}
    }
  };
  _ctor.subPubUniqueIdx = 1;
  _ctor.subRec = {};
  return _ctor;
}();
exports.default = def_Subpub;